package online.flowerinsnow.minecraft.bukkit.manhunt.command;

import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

import static online.flowerinsnow.minecraft.bukkit.manhunt.util.MessageUtils.*;

public class CommandTeamChatCoords implements TabExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
        if (!(sender instanceof Player)) {
            sendMustBePlayer(sender);
            return true;
        }
        if (args.length != 0) {
            sender.sendMessage(parseColor("&7[&a?&7]&b用法: &e/teamchatcoords(tcc)"));
            return true;
        }
        Player player = (Player) sender;
        Location loc = player.getLocation();
        player.performCommand("tc 我现在的坐标是 §e[" + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + "]");
        return true;
    }

    @Override
    public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
        return new ArrayList<>();
    }
}
